// 公共 actions
export default {
  // 获取token
  async getTokenActions({ commit, dispatch, state }) {
    return new Promise((resolve) => {
      setTimeout(async () => {
        const token = 'xxxxxxx';
        commit('setToken', token);
        await dispatch('getUserInfoActions', token);
        console.warn('获取用户信息 :>> ', state.userInfo);
        resolve();
      }, 300);
    });
  },
  // 获取用户信息
  async getUserInfoActions({ commit }, token) {
    console.warn('参数 token :>> ', token);
    return new Promise((resolve) => {
      setTimeout(() => {
        const data = {
          userName: '种子的信仰',
          level: 1,
          email: '5161155585@qq.com',
          phone: '13588888888',
          cityName: '南宁',
        };
        commit('setUserInfo', data);
        resolve();
      }, 300);
    });
  },
};
